#!/bin/bash

echo "Setting up Demo Project on Linux..."

# 安装依赖
if command -v apt-get &> /dev/null; then
    # Debian/Ubuntu
    sudo apt-get update
    sudo apt-get install -y libpqxx-dev postgresql-server-dev-all cmake build-essential
elif command -v yum &> /dev/null; then
    # CentOS/RHEL
    sudo yum install -y libpqxx-devel postgresql-devel cmake gcc-c++ make
elif command -v dnf &> /dev/null; then
    # Fedora
    sudo dnf install -y libpqxx-devel postgresql-devel cmake gcc-c++ make
fi

# 创建构建目录
mkdir -p build
cd build

# 配置和构建
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

echo "Build completed successfully!"
echo "Run: ./src/demo_app"